<html>
<head>
    <title>后台管理系统</title>
    <#assign basePath=request.contextPath>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="icon" href="/images/favicon.png" type="image/x-icon" />
    <link rel="shortcut icon" href="/images/favicon.png" type="image/x-icon" />
    <link rel="bookmark" href="/images/favicon.png" type="image/x-icon" />
    <style>
        a{cursor: pointer;}
    </style>
    <!-- Bootstrap Core CSS -->
    <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="/bootstrap/css/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="/bootstrap/css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="/bootstrap/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- Bootstrap Reset -->
    <link href="/bootstrap/css/bootstrap-reset.css" rel="stylesheet">
    <link rel="stylesheet" href="/bootstrap/css/jquery-ui.min.css">
    <link rel="stylesheet" href="/bootstrap/css/common.css">
    <link href="/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <style>
        .navbar-right{ width: 270px;}
        .dropdown-toggle{ display: inline-block;}
        .dropdown-toggle span{ display: inline-block; text-align: right; line-height: 100%;}
        .dropdown-toggle b{ display: block; font-weight: normal; margin: 25px 0 5px;}
        .head-img{ display: inline-block; position: relative;}
        .head-img img{ width: 55px; height:55px; border-radius: 50%; cursor: pointer;}
        .head-img .input-file-edit{ position: absolute; top: 0; left: 0; width: 55px; height: 55px; opacity: 0;}
    </style>
</head>

<body class="noy">
<input type="hidden" id="_ctx" value=""/>
<div id="wrapper">
    <!-- 头部导航 -->
    <nav class="navbar navbar-default navbar-static-top" role="navigation">
        <div class="navbar-outer">
            <div class="navbar-inner cf">
                <div class="log-wrap lzy-logo"><img src="/images/item/lzy_logo.png" title="龙之游" alt="龙之游" /></div>
                <div class="nav-collapse collapse navbar-responsive-collapse">
                    <ul class="nav" id="header-nav">
                        <li class="active"><a >首页</a></li>
                    </ul>
                </div>
                <div class="navbar-right cf">

                    <div class="dropdown userLogin">
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <span><b>你好！</b>${loginName!}</span>

                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li onclick="changePwd();"><a><i class="fa fa-user fa-fw"></i> 修改密码</a></li>
                            <li onclick="changeLoginName();"><a><i class="fa fa-user fa-fw"></i> 修改登录名</a></li>
                        </ul>
                    </div>
                    <div class="head-img">
                        <input class="obj-input" name="logo" value="" type="hidden">

                        <img class="obj-img" src="http://img1.goods.lzyhll.com/FnYgFQDnzr_RU9hVsLN4-Jog63k7" alt="logo">

                        <span class="input-file-edit">
                            <input data-image="logo" type="file" data-action="goods" onchange="uploadImg(this)">
                        </span>
                    </div>

                    <a class="logout" href="/admin/logout"><span class="fa fa-power-off"></span> 退出</a>
                </div>
            </div>
        </div>
    </nav>

    <!-- Page Content -->
    <div class="row-fluid" id="indexPage" style="display: none;">
        <div class="navbar-default sidebar" role="navigation" >
            <div class="sidebar-nav navbar-collapse">
                <!-- 左侧菜单栏 -->
                <ul class="nav" id="side-menu">
                </ul>
            </div>
        </div>
        <div id="page-wrapper">
            <div class="page-tab">
                <span class="homeTab">首页</span>
            </div>
            <div class="page-cont">
            </div>
        </div>
    </div>
    <div class="row-fluid" id="homeHtml" align="center">
        <h1 style="margin-top: 240px">欢迎来到龙之游工作平台管理中心</h1>
    </div>
    <br/>
    <!-- 分页查询的地址-->
    <#--<div class="panel-body panel-white item-box">-->
        <#--<div class="table-responsive">-->
            <#--<table id="myTable"-->
                   <#--class="table table-hover"-->
                   <#--data-url="${basePath}/appletItem/json"-->
                   <#--data-pageSize="10,50,100" data-method="GET">-->
                <#--<thead>-->
            <#--</table>-->
        <#--</div>-->
    <#--</div>-->


<script src="/bootstrap/js/jquery.min.js" type="text/javascript"></script>
<script src="/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="/bootstrap/js/metisMenu.min.js" type="text/javascript"></script>
<!-- layer JavaScript -->
<script src="/bootstrap/plugin/layer/layer.js" type="text/javascript"></script>
<script src="/bootstrap/js/jquery-ui.min.js" type="text/javascript"></script>
<script src="/bootstrap/js/common.js" type="text/javascript"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/bootstrap-validator/0.5.3/js/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/bootstrap-validator/0.5.3/js/language/zh_CN.js"></script>
<script type="text/javascript">
    $(window).bootstrapValidator || document.write('<script src="/bootstrap/js/bootstrapValidator.min.js"><\/script>'+
            '<script src="/bootstrap/js/bootstrapValidator-zh_CN.js"><\/script>');
</script>

<script src="/bootstrap/js/sb-admin-2.js" type="text/javascript"></script>

<script type="text/javascript" src="/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">
    $(function () {
        $('#start_visit_time').datetimepicker({
            minView: "month", //选择日期后，不会再跳转去选择时分秒
            format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
            language: 'zh-CN', //汉化
            autoclose:true //选择日期后自动关闭
        });
        $('#end_visit_time').datetimepicker({
            minView: "month", //选择日期后，不会再跳转去选择时分秒
            format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
            language: 'zh-CN', //汉化
            autoclose:true //选择日期后自动关闭
        });
    });
</script>

<script type="text/javascript">
    //全局的AJAX访问，处理AJAX清求时SESSION超时
    $.ajaxSetup({
        contentType:"application/json;charset=utf-8",
        complete:function(XMLHttpRequest,textStatus){
            //通过XMLHttpRequest取得响应头，sessionStatus
            var sessionStatus = XMLHttpRequest.getResponseHeader("sessionStatus");
            if(sessionStatus == "timeout"){
                //跳转的登录页面
                layer.confirm('您登录的时间超时，请重新登录', {
                    btn: ['确定', '取消'], //按钮
                    icon: 6
                }, function(){
                    top.location.replace('/admin/login');
                }, function(){
                });
            }
        }
    });

    function changePwd() {
        //iframe层-父子操作
        var index = layer.open({
            type: 2,
            area: ['900px', '350px'],
            offset: [100,(($(window).width()-900)/2)],
            title: '修改密码',
            content: ['/admin/manager/changePwd', 'no']
        });
    }

    function changeLoginName() {
        //iframe层-父子操作
        var index = layer.open({
            type: 2,
            area: ['600px', '300px'],
            //offset: [100,(($(window).width()-700)/2)],
            title: '修改登录名',
            content: ['/admin/manager/changeLoginName', 'no']
        });
    }

    function showMessage() {
        $('#indexPage').show();
        $('#homeHtml').hide();
    }

    /**
     * page-wrapper 自适应高度
     */
    function frameresize(){
        var winheight = $(window).height();
        var iframeheight = winheight;
        $('#page-wrapper').css('height', iframeheight - 154 + 'px');
        $('#page-wrapper .page-cont').css('height', iframeheight - 174 + 'px');
    };

    if(window.attachEvent){
        document.getElementById("page-wrapper").attachEvent('onload', frameresize);
    }
    else{
        document.getElementById("page-wrapper").addEventListener('load', frameresize, false);
    }

    $(window).resize(frameresize);

    frameresize();

    //2017-6-1
    var appUrl = $('#_ctx').val();
    //上传图片
    /**
     * 调用方法
     * data-action="goods"  商品图片
     * data-action="icon"  icon
     * data-action="image" 测试图片
     * data-action="base"  证件相关
     <input class="obj-input" name="banner" value="" type="hidden">
     <img class="obj-img" src="" style="display:none">
     <input id="banner" data-image="banner" type="file"  data-action="goods" onchange="uploadImg(this)">
     默认单图 多图事件：uploadImg(this,true)
     appUrl 路径
     <input type="hidden" id="_ctx" value=""/>
     **/
    var flag = false;//flag是否多张
    var uploadImg = function(obj){
        //创建FormData对象
        var data = new FormData();
        var at = $(obj).attr("data-image");
        var action = $(obj).attr("data-action");
        //为FormData对象添加数据
        data.append('image', $(obj)[0].files[0]);

        //判定图片大小和尺寸
        if(getPhotoSize(obj,1)){
            var objUrl = getObjectURL(obj.files[0]);
            getImageWidth(objUrl, function(w, h) {
                var size = "?" + w + "/" + h;
                if (w > 750 || h > 750) {
                    alert("图片尺寸太大，请处理成不大于750px");
                    return false;
                }
                else{
                    $.ajax({
                        url: appUrl + '/admin/manager/avatar/upload',
                        type: 'POST',
                        data: data,
                        cache: false,
                        contentType: false,
                        processData: false,
                        success: function (res) {
                            //获取图片尺寸
                            res = res + size;
                            //单图
                            var _this = $(obj).parent();
                            _this.hide();
                            //预先取消绑定 -- 兼容webkit
                            _this.siblings(".obj-img").off("click");
                            _this.siblings(".obj-img").attr("src", res).show().on("click", function () {
                                $(obj).click();
                            });
                            _this.siblings(".obj-input").val(res).change();
                            _this.siblings("input.old-val").val(res).change();//编辑页面直接修改input的值
                        },
                        error: function () {
                            console.log("上传失败")
                        }
                    });
                }
            });
        }
        //获取图片原始尺寸方法
        function getImageWidth(url,callback){
            var img = new Image();
            img.src = url;
            // 如果图片被缓存，则直接返回缓存数据
            if(img.complete){
                callback(img.width, img.height);
            }
            // 完全加载完毕的事件
            else{
                img.onload = function(){
                    callback(img.width, img.height);
                }
            }
        }
        //判断图片大小
        function getPhotoSize(obj,imgSize){
            var photoExt = obj.value.substring(obj.value.lastIndexOf(".")+1).toLowerCase();//获得文件后缀名
            if(photoExt!='jpg'&&photoExt!='jpeg'&&photoExt!='bmp'&&photoExt!='png'){
                alert("图片格式必须是.jpg/.jpeg/.bmp/.png!");
                return false;
            }
            var imgSize = imgSize || 1;
            var fileSize = 0;
            var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
            if (isIE && !obj.files) {
                var filePath = obj.value;
                var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
                var file = fileSystem.GetFile (filePath);
                fileSize = file.Size;
            }else {
                fileSize = obj.files[0].size;
            }
            fileSize=Math.round(fileSize/1024*100)/100; //单位为KB
            if(fileSize>imgSize*1024){
                alert("图片最大为"+imgSize+"M，请重新上传!");
                return false;
            }
            return fileSize;
        }
        //获取图片临时url -- 1.判断图片尺寸 2.可实现预览
        function getObjectURL(file) {
            var url = null ;
            if (window.createObjectURL!=undefined) { // basic
                url = window.createObjectURL(file) ;
            } else if (window.URL!=undefined) { // mozilla(firefox)
                url = window.URL.createObjectURL(file) ;
            } else if (window.webkitURL!=undefined) { // webkit or chrome
                url = window.webkitURL.createObjectURL(file) ;
            }
            return url ;
        }
    };
</script>
</body>
</html>


























